package 华为OD机试真题2023.进阶题;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class HJ09_数字加减游戏 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试真题2023/进阶题/input/09.txt"));
        int s = in.nextInt();
        int t = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int res = 0;
        int add = s, sub = s;
        while (true) {
            if ((t - add) % b == 0) {
                break;
            }
            if ((t - sub) % b == 0) {
                break;
            }
            add += a;
            sub -= b;
            res++;
        }
        System.out.println(res);
    }
}
